#include<bits/stdc++.h>

using namespace std;

const int N = 210;

int n,m;
int link[N][N];
int pd[N];
int boy[N];

bool find(int x)
{
	for(int i = 1; i <= m; i ++ )
	{
		if(link[x][i] && !pd[i])
		{
			pd[i] = 1;
			if(boy[i] == 0 || find(boy[i]))
			{
				boy[i] = x;
				return 1;
			}
		}
	}
	return 0;
}

int main()
{
	while(cin>>n>>m)
	{
		memset(link, 0, sizeof(link));
		memset(boy, 0, sizeof(boy));
		for(int i = 1; i <= n; i ++ )
		{
			int k;
			cin>>k;
			for(int j = 1; j <= k; j ++ )
			{
				int a;
				cin>>a;
				link[i][a] = 1;
			}
		}
		int sum = 0;
		for(int i = 1; i <= n; i ++ )
		{
			memset(pd, 0, sizeof(pd));
			if(find(i)) sum++;
		}
		cout<<n - sum<<endl;		
	}
	return 0;
}
